﻿namespace Sidvall.CodeGenerator
{
	public class DomainObjectRelationFieldCollection : System.Collections.ObjectModel.KeyedCollection<string, DomainObjectRelationField>
	{
		#region Business Members

		#region GetKeyForItem

		protected override string GetKeyForItem(DomainObjectRelationField item)
		{
			if (item == null)
				throw new System.ArgumentNullException("item");

			return DomainObjectRelationField.GetKey(item);
		}

		#endregion
		#region ToString

		public override string ToString()
		{
			if (this.Count == 1)
				return this[0].ToString();
			return this.Count + " fields";
		}

		#endregion

		#endregion
		#region Constructors

		public DomainObjectRelationFieldCollection()
			: base(System.StringComparer.OrdinalIgnoreCase)
		{
		}

		#endregion
	}
}
